//
//  FSMenuView.m
//  TextPage
//
//  Created by 刘沿 on 16/6/30.
//  Copyright © 2016年 刘沿. All rights reserved.
//

#import "FSMenuView.h"
#import "UIView+HMFrame.h"

@interface FSMenuView ()

@property (weak, nonatomic) IBOutlet UIButton *foodBtn;

@property (weak, nonatomic) IBOutlet UIButton *meetBtn;


@property (weak, nonatomic) IBOutlet UIView *animateView;


@end


@implementation FSMenuView

- (instancetype) init
{
    if (self = [super init])
    {
        self = [[[NSBundle mainBundle] loadNibNamed:@"FSMenuView" owner:nil options:nil] lastObject];
    }
    return self;
}

- (void)awakeFromNib
{
    //默认选中左边按钮
    
    self.foodBtn.selected = YES;
}

//食堂管理点击
- (IBAction)foodBtnClick:(id)sender {
    
    if (self.scollView) {
        
        [self.scollView setContentOffset:CGPointZero animated:YES];
    }
    
}

//会议室管理点击
- (IBAction)meetingBtnClick:(id)sender {
    
    if (self.scollView) {
        [self.scollView setContentOffset:CGPointMake(self.scollView.contentSize.width / 2.f, 0) animated:YES];
    }
    
    
}

-(void)setWidth:(CGFloat)width{
    _width = width;

    self.w = width;
}

- (void)animateViewProgress:(CGFloat)progress{
//让下面的线动起来
    if (progress > 0 && progress < 1) {
        
        self.animateView.x = progress * self.w;
        
    }

    if (progress > 1/4 && progress <=1) {
        
        [self selectMeetBtn];
        
    }else {
    
        [self selectFoodBtn];
    }

}

//切换选中按钮
- (void)selectFoodBtn{

    if (!self.foodBtn.selected) {
        
        self.foodBtn.selected = YES;
        self.meetBtn.selected = NO;
    }

}


- (void)selectMeetBtn{

    if (!self.meetBtn.selected) {
        
        self.meetBtn.selected = YES;
        
        self.foodBtn.selected = NO;
    }

}




@end



















